import request from '@/utils/request'

export const analysisApi = {
  // 获取仪表盘统计数据
  getDashboardStats(params) {
    return request({
      url: '/analysis/dashboard/',
      method: 'get',
      params
    })
  },

  // 获取趋势数据
  getTrendData(params) {
    return request({
      url: '/analysis/trend/',
      method: 'get',
      params
    })
  },

  // 获取来源分布
  getSourceDistribution(params) {
    return request({
      url: '/analysis/distribution/',
      method: 'get',
      params
    })
  },

  // 获取话题分析
  getTopicAnalysis(params) {
    return request({
      url: '/analysis/topics/',
      method: 'get',
      params
    })
  },

  // 获取情感分析
  getSentimentAnalysis(params) {
    return request({
      url: '/analysis/sentiment/',
      method: 'get',
      params
    })
  },

  // 获取用户排行
  getUserRankings(params) {
    return request({
      url: '/analysis/users/rankings/',
      method: 'get',
      params
    })
  },

  // 数据源管理
  getDataSources() {
    return request({
      url: '/analysis/sources/',
      method: 'get'
    })
  },

  createDataSource(data) {
    return request({
      url: '/analysis/sources/',
      method: 'post',
      data
    })
  },

  updateDataSource(id, data) {
    return request({
      url: `/analysis/sources/${id}/`,
      method: 'put',
      data
    })
  },

  deleteDataSource(id) {
    return request({
      url: `/analysis/sources/${id}/`,
      method: 'delete'
    })
  },

  testDataSourceConnection(id) {
    return request({
      url: `/analysis/sources/${id}/test_connection/`,
      method: 'post'
    })
  },

  // 微博数据可视化
  getWeiboVisualization(params) {
    return request({
      url: '/analysis/weibo/visualization/',
      method: 'get',
      params
    })
  },

  // 分析任务管理
  getTasks() {
    return request({
      url: '/analysis/tasks/',
      method: 'get'
    })
  },

  getTaskDetail(id) {
    return request({
      url: `/analysis/tasks/${id}/`,
      method: 'get'
    })
  },

  createTask(data) {
    return request({
      url: '/analysis/tasks/',
      method: 'post',
      data
    })
  },

  startTask(id) {
    return request({
      url: `/analysis/tasks/${id}/start/`,
      method: 'post'
    })
  },

  cancelTask(id) {
    return request({
      url: `/analysis/tasks/${id}/cancel/`,
      method: 'post'
    })
  },

  // 分析结果
  getResults() {
    return request({
      url: '/analysis/results/',
      method: 'get'
    })
  },

  getResultDetail(id) {
    return request({
      url: `/analysis/results/${id}/`,
      method: 'get'
    })
  },

  // 获取报表列表
  getReports(params) {
    return request({
      url: '/analysis/reports/',
      method: 'get',
      params
    })
  },

  // 获取报表详情
  getReportDetail(id) {
    return request({
      url: `/analysis/reports/${id}/`,
      method: 'get'
    })
  },

  // 创建报表
  createReport(data) {
    return request({
      url: '/analysis/reports/',
      method: 'post',
      data
    })
  },

  // 删除报表
  deleteReport(id) {
    return request({
      url: `/analysis/reports/${id}/`,
      method: 'delete'
    })
  },

  // 导出报表
  exportReport(id) {
    return request({
      url: `/analysis/reports/${id}/export/`,
      method: 'post',
      responseType: 'blob'
    })
  }
} 